<?PHP
if (!session_start()) { session_start(); };
/*if (!isset($_SESSION['lgnapproved'])) {
	die(header('Location: login.php'));
}*/

include("functions.php");
include("cnnxn.php");
connect();

if (isset($_POST['submit'])) {

$dateadded=date("Y-m-d");

$fieldnames="";
$tempvalue="";
$modstring="";
while (list($key,$value) = each($_POST)) {
if ($value!='modify') {
	if (ctype_digit($value)) {
       $tempvalue=$value;
	} else {
       $tempvalue='"'.addslashes($value).'"';
	}
	$modstring=$modstring.$key.'='.$tempvalue.',';
}
}


$fieldnames=substr_replace($fieldnames,"",-8);
$modstring=substr_replace($modstring,"",-1);
$SQLmod='UPDATE av_organization SET '.$modstring.' WHERE id='.$_GET['id'].';';
$sendit_mod=mysqli_query($db,$SQLmod) or die(mysqli_error($db));
die(header("Location: av_organization_viewall.php"));
} else {
$SQLdet='SELECT * FROM av_organization WHERE id='.$_GET['id'].';';
//print $SQLdet;
$sendit_det=mysqli_query($db,$SQLdet) or die(mysqli_error($db));
$RSdet=mysqli_fetch_object($sendit_det) or die(mysqli_error($db));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>daleclark.net</title>
<link type="text/css" rel="stylesheet" href="adminstyles.css" />
</head>
<body>
<div id="adminwrapper">
<div id="adminlogo"></div>
<?PHP navigation(); ?>
<div id="admincontent">
<h3>Modify or Delete Organization</h3>
<form name="addForm" method="POST" action="av_organization_mod.php?id=<?PHP print $_GET['id']; ?>">
<p><span class="label">Organization Name</span><span class="inputbox"><input name="orgname" type="text" value="<?PHP print $RSdet->orgname; ?>" /></span></p>
<p><span class="label">Organization Location</span><span class="inputbox"><input name="orglocation" type="text" value="<?PHP print $RSdet->orglocation; ?>" /></span></p>
<p><span class="label">Organization Contact Person</span><span class="inputbox"><input name="orgcontactperson" type="text" value="<?PHP print $RSdet->orgcontactperson; ?>" /></span></p>
<p><span class="label">Organization Contact Number</span><span class="inputbox"><input name="orgcontactnumber" type="text" value="<?PHP print $RSdet->orgcontactnumber; ?>" /></span></p>
<p><span class="label">Organization Email</span><span class="inputbox"><input name="orgemail" type="text" value="<?PHP print $RSdet->orgemail; ?>" /></span></p>
<p><input type="submit" value="modify" name="submit" /></p></form>
<p><a href="av_organization_del.php?id=<?PHP print $_GET['id']; ?>" class="deletelink">DELETE RECORD</a></p></div>
</div>
</body>
</html>
<?PHP
mysqli_close($db);
?>